import java.util.*;

public abstract class MobileSprite extends Sprite{
	/**A public method for changing the sprite's location
	 * on the grid
	 */
	private Collection<Hex> path;
	boolean moved;
	protected int moveCount;
	double slope;
	protected int[] oldLocation;
	protected int xDistance, yDistance;
	
	//slope direction of current movement
	void setParameters(HexGrid world){
		int oldx = world.get_hex(oldLocation).xLoc;
		int oldy = world.get_hex(oldLocation).yLoc;
		int newx = world.get_hex(location).xLoc;
		int newy = world.get_hex(location).yLoc;
		xDistance = newx - oldx;
		yDistance = newy - oldy;
	}
	
	
	public void setMoved(boolean m){
		moved = m;
	}
	
	public int[] getOldLocation()
	{
		return oldLocation;
	}
	
	//returns true upon finding a path, false otherwise
	private boolean findPath(int[] goal,HexGrid world){return false;}/*
	{
		if(!world.validLocation(goal))
			return false;
		
		List<Hex> open = new ArrayList<Hex>();
		Set<Hex> closed = new HashSet<Hex>();
		this.path = new ArrayList<Hex>();
		
		//g = cost from start
		//h = estimated distance from current node to goal
		//f = g + h
		List<Integer> f_scores = new ArrayList<Integer>();
		List<Integer> g_scores = new ArrayList<Integer>();
		List<Integer> h_scores = new ArrayList<Integer>();
		
		Hex startHex,goalHex,curr;
		Collection<Hex> neighbors;
		startHex = world.get_hex(this.location); 
		goalHex = world.get_hex(goal);
		
		open.add(startHex);
		g_scores.add(0);
		h_scores.add(startHex.manhattanDistance(goalHex));
		f_scores.add(h_scores.get(0));
		
		int temp_g,currIndex;
		while(!open.isEmpty()){
			currIndex = minIndex(f_scores);
			curr = open.get(currIndex);
			if(curr.equals(goalHex))
				return true;
			neighbors = world.get_neighbors(curr);

			for(Hex adj:neighbors){
				if(!closed.contains(adj)){
					temp_g = g_scores.get(currIndex);
					
					
				}
			}
		}
	}
	*/
	private int minIndex(List<Integer> c){
		int result = 0;
		int min = c.get(0);
		int tmp;
		for(int i = 1; i<c.size(); i++){
			tmp = c.get(i); 
			if(tmp<min){
				min = tmp;
				result = i;
			}
		}
		return result;
	}
	
	public abstract boolean move(HexGrid world);
	
}
